<%-- 
    Document   : Upload1
    Created on : 2014/8/19, 下午 02:19:29
    Author     : LENOVO
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    String id = request.getParameter("id");
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb","root","root");
    Statement st = con.createStatement();
    String sql ="select id , username , tel , birthday from person where id=" + id;
    System.out.println(sql);
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>修改</h1>
        <%
            ResultSet rs = st.executeQuery(sql);
            if(rs.next())
            {
                //String id = rs.getString("id");
                String username = rs.getString("username");
                String tel = rs.getString("tel");
                String birthday = rs.getString("birthday");
        %>
            <form action="Upload2.jsp">
                姓名：<input type="text" name="username" maxlength="10" size="20" value="<%= username %>"> <br>
                電話：<input type="text" name="tel" maxlength="10" size="20" value="<%= tel %>"> <br>
                生日：<input type="text" name="birthday" maxlength="10" size="20" value="<%= birthday %>"> <br>
                <input type="hidden" name="id" value="<%= id %>">
                <input type="submit" value="修改">
            </form>
        <%
                //out.println(id + "," + username + "," + tel + "," + birthday + "<br>");
            }
            else
            {
                out.println("查無資料");
            }    
            rs.close();
            st.close();
            con.close();
        %>
        
    </body>
</html>
